<?php
/* Functions.php */

function dbconnect()
{
	$con = @mysql_connect(DB_SERVER, DB_USER, DB_PASS);
	@mysql_select_db(DB_NAME, $con);
	if(!$con)
	{
			die("Could not connect to the Database");
			return false;
	}
	return $con;
}

function get_dropdown_options($table,$column)
{
	$sql="SELECT id,".$column." from ".$table;
	$result=mysql_query($sql);
	$options="";
	while ($row=mysql_fetch_array($result)) {
		$id=$row["id"];
		$name=$row["$column"];
		$options.="<option value=\"".$id."\">".$name."</option>";
	}
	return $options;
}

function get_unique_dropdown_options($table,$column)
{
	$sql="select distinct ".$column." from ".$table;
	$result=mysql_query($sql);
	$options="";
	while ($row=mysql_fetch_array($result)) {
		$name=$row["$column"];
		$options.="<option value=\"".$name."\">".$name."</option>";
	}
	return $options;
}
 
 
?>